package controllers.swagger;

import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import play.Play;
import play.mvc.Controller;
import play.mvc.Router;
import play.mvc.Router.ActionDefinition;
import play.mvc.Router.Route;
import ret.Ret;
import swagger.annotations.ApiInfo;
import utils.ApidocGenerate;

public class Swagger extends Controller {

    public static void index() {
        render();
    }

    public static void apidocs() {
        List<Class<?>> clzs = Play.classloader.getAssignableClasses(
                Controller.class).stream().filter(c -> c.getAnnotation(ApiInfo.class) != null).collect(Collectors.toList());
        renderJSON(ApidocGenerate.scanClasses("127.0.0.1:9000", "/", clzs));
    }
}
